//网站站点管理

//输入logo地址，显示logo图片
$(document).ready(function(){
	$("#weblogourl").focusout(function(e) {
        $("#logoyulan").attr("src",$("#weblogourl").val())
    });
});
$(document).ready(function(){
	$("#sitelogourl").focusout(function(e) {
        $("#logolook").attr("src",$("#sitelogourl").val())
    });
});



//添加
function addwebsite(){
	
	var sitename= $("#webname").attr("value");
	var siteurl= $("#weburl").attr("value");
	var sitelogo = $("#weblogourl").attr("value");
	var sitedesc = $("#zhandianmiaoshu").val();
	sitename = sitename.replace(/(^\s*)|(\s*$)/g,"");
	siteurl = siteurl.replace(/(^\s*)|(\s*$)/g,"");
	sitelogo = sitelogo.replace(/(^\s*)|(\s*$)/g,"");
	sitedesc = sitedesc.replace(/(^\s*)|(\s*$)/g,"");
	if(sitename=="" || siteurl=="" || sitelogo=="" || sitedesc==""){
		alert("有为空的选项，无法添加");
	}else{
		$.ajax({
		type:"post",
		url:"tool/website/addwebsite.jsp",
		dataType:"html",
		data:{	
			sitename:sitename,
			siteurl:siteurl,
			sitelogo:sitelogo,
			sitedesc:sitedesc
		},
		success:function(issuccess,textStatus){
			alert(issuccess);
			location.assign("website_manager.jsp") 
			
		}
		});
	}
}

//弹出修改页面，并显示所选修改的内容
function displaymodific(idnum)
{
	var siteid = "#siteid_"+idnum;
$.ajax({
type:"post",
url:"tool/website/displaymodifwebsite.jsp",
dataType:"text",
data:{
	siteid:$(siteid).text(),
},
success:function(responseText,textStatus){
	
	var jsonresult=eval("(" + responseText + ")");
	
	var id = jsonresult.id;
	var sitename = jsonresult.siename;
	var siteurl = jsonresult.siteurl;
	var sitelogo = jsonresult.sitelogo;
	var sitedesc = jsonresult.sitedesc;
	
	
	
	$("#sitename").val(sitename);
	$("#siteurl").val(siteurl);
	$("#sitelogourl").val(sitelogo);
	$("#logolook").attr("src",sitelogo);
	$("#sitedesc").val(sitedesc);
	$("#siteid").val(id);
	
	popupDiv('displaywebsite');
}
});
}

//修改站点
function modificwebsite(){
	var siteid = $("#siteid").attr('value') ;
	var sitename= $("#sitename_0").attr("value");
	var sitelogo = $("#sitelogourl").attr("value");
	var sitedesc = $("#sitedesc").val();
$.ajax({
type:"post",
url:"tool/website/modificwebsite.jsp",
dataType:"html",
data:{
	siteid:siteid,
	sitename:sitename,
	sitelogo:sitelogo,
	sitedesc:sitedesc
},
success:function(issuccess,textStatus){
	alert(issuccess);
	window.location.reload();
}
});
}
//删除所选站点
function deletewebsite(idnum)
{
	var sitename = "#sitename_"+idnum;
$.ajax({
type:"post",
url:"tool/website/delete_website.jsp",
dataType:"html",
data:{
	sitename:$(sitename).text(),
},
success:function(issuccess,textStatus){
	
	alert(issuccess);
	window.location.reload()
}
});
}
//tab切换
$(document).ready(function(){ 
var intervalID; 
var curLi; 
$("#newzd_tit samp a").mouseover(function(){ 
curLi=$(this); 
intervalID=setInterval(onMouseOver,250); 
}); 
function onMouseOver(){ 
$(".cur-sub-con").removeClass("cur-sub-con"); 
$(".sub-con").eq($("#newzd_tit samp a").index(curLi)).addClass("cur-sub-con"); 

$(".cur").removeClass("cur"); 
curLi.addClass("cur"); 
} 
$("#newzd_tit samp a").mouseout(function(){ 
clearInterval(intervalID);
$(".inputtishi").css("display", "none");
}); 

$("#newzd_tit samp a").click(function(){
clearInterval(intervalID); 
$(".cur-sub-con").removeClass("cur-sub-con");

$(".sub-con").eq($("#newzd_tit samp a").index(curLi)).addClass("cur-sub-con"); 
$(".cur").removeClass("cur"); 
curLi.addClass("cur"); 
});
});